package com.ljx.itbbs.server.user.service.handler;

import cn.hutool.extra.spring.SpringUtil;
import com.ljx.itbbs.common.domain.entity.UserEntity;
import com.ljx.itbbs.server.article.service.ArticleService;
import com.ljx.itbbs.server.article.service.PlateService;
import com.ljx.itbbs.server.user.domain.dto.UserPlaterDto;
import com.ljx.itbbs.server.user.service.UserService;

import java.util.TimerTask;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-05-11  21:08
 */
public class UserAsyncHandler {

    /**
     * 更新版主列表
     * @param uid
     * @param plateId
     * @return
     */
    public static TimerTask updatePlateList(Long uid, Long plateId) {
        return new TimerTask() {
            @Override
            public void run() {
                UserEntity userEntity = SpringUtil.getBean(UserService.class).getUserInfoById(uid);
                SpringUtil.getBean(PlateService.class).adminUpdatePlaterList(UserPlaterDto.builder()
                        .plateId(plateId)
                        .uid(uid)
                        .nickname(userEntity.getNickname())
                        .build());
            }
        };
    }


    public static TimerTask cancelPlater(Long uid, Long plateId) {
        return new TimerTask() {
            @Override
            public void run() {
                SpringUtil.getBean(PlateService.class).adminCancelPlater(uid, plateId);
            }
        };
    }
}
